<?php
require_once 'config.php'; 
require_once 'Tools.class.php'; 
require_once 'User.class.php'; 
require_once 'HTML.class.php'; 
class Super{
    private $line1="-----------------\n";
    private $line2="===============\n";
	
    public function admin($opid){
        $s=array('201211006012');
        $xh=User::getXH($opid);
        for($i=0;$i<count($s);$i++){
            if($xh==$s[$i]){
                return true;
            }
        }
        return false;
    }


    //学生信息
    public function getStudentInfo($xh){

        if(strlen($xh)==12){
            $code=Tools::getHttp(DZU_URL."stuinfo.asp?xh=".$xh);
        }
        $lib = explode("@JBXXB",$code);
        for($i=1;$i<count($lib);$i++){
            $XM = Tools::getInfo(trim($lib[$i]),"XM");
            $XB = Tools::getInfo(trim($lib[$i]),"XB");
            $ZZMM = Tools::getInfo(trim($lib[$i]),"ZZMM");
            $MZ = Tools::getInfo(trim($lib[$i]),"MZ");
            $JG = Tools::getInfo(trim($lib[$i]),"JG");
            $XY = Tools::getInfo(trim($lib[$i]),"XY");
            $ZYMC = Tools::getInfo(trim($lib[$i]),"ZYMC");
            $XZB = Tools::getInfo(trim($lib[$i]),"XZB");
            $XXXS = Tools::getInfo(trim($lib[$i]),"XXXS");
            $XSLB = Tools::getInfo(trim($lib[$i]),"XSLB");
            $CC = Tools::getInfo(trim($lib[$i]),"CC");
            $RXZF = Tools::getInfo(trim($lib[$i]),"RXZF");
            $XZH = Tools::getInfo(trim($lib[$i]),"XZH");
            $CSRQ = Tools::getInfo(trim($lib[$i]),"CSRQ");
            $DQSZJ = Tools::getInfo(trim($lib[$i]),"DQSZJ");
            $RXRQ = Tools::getInfo(trim($lib[$i]),"RXRQ");
            $BYRQ = Tools::getInfo(trim($lib[$i]),"BYRQ");
            $MM = Tools::getInfo(trim($lib[$i]),"MM");
            $XH = Tools::getInfo(trim($lib[$i]),"XH");
            $XYKH = Tools::getInfo(trim($lib[$i]),"XYKH");
            $XSSJ = Tools::getInfo(trim($lib[$i]),"XSSJ");
            $SFZH = Tools::getInfo(trim($lib[$i]),"SFZH");
            $YHKH = Tools::getInfo(trim($lib[$i]),"YHKH");

            $str .= HTML::makeList3("姓名",$XM);
            $str .= HTML::makeList3("性别",$XB);
            $str .= HTML::makeList3("民族",$MZ);
            $str .= HTML::makeList3("政治面貌",$ZZMM);
            $str .= HTML::makeList3("籍贯",$JG);
            $str .= HTML::makeList3("学院名称",$XY);
            $str .= HTML::makeList3("专业名称",$ZYMC);
            $str .= HTML::makeList3("班级名称",$XZB);
            $str .= HTML::makeList3("层次",$CC);
            $str .= HTML::makeList3("入学总分",$RXZF);
            $str .= HTML::makeList3("学制",$XZH);
            $str .= HTML::makeList3("年级",$DQSZJ);
            $str .= HTML::makeList3("入学日期",$RXRQ);
            $str .= HTML::makeList3("毕业日期",$BYRQ);
            $str .= HTML::makeList3("出生日期",$CSRQ);
            $str .= HTML::makeList3("密码",Tools::JWMM($MM));
            $str .= HTML::makeList3("学号",$XH);
            $str .= HTML::makeList3("校园卡号",$XYKH);
            $str .= HTML::makeList3("手机号",$XSSJ);
            $str .= HTML::makeList3("身份证号",$SFZH);
            $str .= HTML::makeList3("银行卡号",$YHKH);

        }//for

        $tpl=file_get_contents(API_URL."weixin/web/info.html");
        $tpl=str_replace("_TITLE", '资料查看', $tpl);
        $tpl=str_replace("_SFZH", $SFZH, $tpl);
        $tpl=str_replace("_XYKH", $XYKH, $tpl);
        $tpl=str_replace("_LIST", $str, $tpl);
        return $tpl;
    } 

    public function SearchStudent($a,$b,$c,$opid,$code){
        if($this->admin($opid)){
            if($a!='' && $b!='' && $c!=''){
                if($b=='LIKE')$c='%'.$c.'%';
                $code=Tools::getHttp(DZU_URL."search.asp?a=".urlencode($a)."&b=".urlencode($b)."&c=".urlencode($c)."");
                Tools::SendMMS("18315911332","超级权限\n[".User::getXM($opid)."]搜索[".$a." ".$b." ".$c."]");
            }
            $lib = explode("@XSB",$code);
            for($i=1;$i<count($lib);$i++){
                $XH = Tools::getInfo(trim($lib[$i]),"XH");
                $SFZH = Tools::getInfo(trim($lib[$i]),"SFZH");
                $XM = Tools::getInfo(trim($lib[$i]),"XM");
                $XB = Tools::getInfo(trim($lib[$i]),"XB");
                $XY = Tools::getInfo(trim($lib[$i]),"XY");
                $ZYMC = Tools::getInfo(trim($lib[$i]),"ZYMC");
                $DQSZJ = Tools::getInfo(trim($lib[$i]),"DQSZJ");

                if($XB=='男'){
                    $image='boy.png';
                }else{
                    $image='girl.png';
                }
                $str .= HTML::makeList2($image,$XM."(".$DQSZJ."级)",$ZYMC,API_URL."weixin/web/index.php?action=xsxx&opid=".$opid."&xh=".$XH);
            }//for
            if($str==''){
                $str=HTML::makeListNULL("没有搜索结果");
            }
        }else{
            $str=HTML::makeListNULL("无此权限");
        }
        
        $tpl=file_get_contents(API_URL."weixin/web/list.html");
        $tpl=str_replace("_FORM", $this->getFrom($opid,$a,$b,$c), $tpl);
        $tpl=str_replace("_TITLE", '搜索('.(count($lib)-1).')', $tpl);
        $tpl=str_replace("_LIST", $str, $tpl);
        return $tpl;
    } 

    function getFrom($oid,$a,$b,$c){
        $str.='<form action="" method="get">';
        $str.='&nbsp;&nbsp;';
        $str.='<select name="a" class="searcha">';
        $str.='<option value="XM">字段：姓名</option>';
        $str.='<option value="XH">字段：学号</option>';
        $str.='<option value="XB">字段：性别</option>';
        $str.='<option value="MZ">字段：民族</option>';
        $str.='<option value="JG">字段：籍贯</option>';
        $str.='<option value="XY">字段：学院</option>';
        $str.='<option value="ZYMC">字段：专业</option>';
        $str.='<option value="XZB">字段：班级</option>';
        $str.='<option value="CSRQ">字段：出生日期</option>';
        $str.='<option value="SFZH">字段：身份证号</option>';
        $str.='<option value="RXRQ">字段：入学日期</option>';
        $str.='<option value="BYRQ">字段：毕业日期</option>';
        $str.='<option value="ZZMM">字段：政治面貌</option>';
        $str.='<option value="CC">字段：层次</option>';
        $str.='</select>';
        $str.='<select name="b" class="searchb">';
        $str.='<option value="=">运算符：等于</option>';
        $str.='<option value="!=">运算符：不等</option>';
        $str.='<option value="LIKE">运算符：包含</option>';
        $str.='</select>';
        $str.='<br />';
        $str.='&nbsp;&nbsp;';
        $str.='<input name="c" value="'.str_replace('%', '', $c).'" class="searchc" placeholder="点击此处输入关键字" />';
        $str.='<input type="hidden" name="opid" value="'.$oid.'" />';
        $str.='<input type="hidden" name="action" value="xxcx" />';
        $str.='&nbsp;&nbsp;<input class="cbtn" type="submit" name="submit" value="搜索" />';
        $str.='</form>';

        return $str;
    }

}
?>